<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      function Star(uname, age) {
        this.uname = uname;
        this.age = age;
        // this.sing = function () {
        //   console.log("ddd");
        // };
      }
      Star.prototype.sing = function () {
        console.log("ddd");
      };

      var ldh = new Star("刘德华", 18);
      var zxu = new Star("张学友", 18);
      ldh.sing();
      zxy.sing();
      //   一般情况下，公共属性定义到构造函数里面，公共的方法放到原型对象上
    </script>
  </head>
  <body></body>
</html>
